home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / PBLIB1 / PROGS / DDIR.PAS < prev    next >
Pascal/Delphi Source File  |  1994-05-03  |  3KB  |  134 lines

  1. (*PAGE*)
  2. PROGRAM DDIR;
  3.  
  4. {$M 20000,0,655000}
  5.  
  6. Uses DOS, PbMISC, PbDATA, PbOBJS, PbPARMS, PbOUT0;
  7.  
  8. {
  9. Description : DDIR - simple DDIR
  10.  
  11. Author      : Howard Richoux
  12. Date        : 12/27/93
  13. Last revised: 2/18/94 New libraries
  14. Application : IBM PC and compatibles, done in Turbo Pascal 7.0
  15. Status      : Placed in the Public Domain by HNR Software 1/29/94
  16. Published in: none
  17.  
  18. }
  19. var files    : STRA_object;
  20.  
  21. var filespec : string;
  22.     err      : byte;
  23.     root     : string;
  24.     totals   : searchrec;
  25.     totfiles : integer;
  26.  
  27. { SearchRec - for reference
  28.     type searchrec = record
  29.            fill  : array[1..21] of byte;
  30.            attr  : byte;
  31.            time  : longint;
  32.            size  : longint;
  33.            name  : string[12];
  34.            end;
  35. }
  36.  
  37.  
  38.  
  39. {*****************************************************************}
  40.  
  41. Procedure DealWithIt( var sr : SearchRec; p : pathstr);
  42. var s : string;
  43.      begin
  44.      inc(totfiles);
  45.      totals.size := totals.size + SR.size;
  46.      if SR.time > totals.time then totals.time := SR.time;
  47.      s := FmtSearchRec(SR);
  48.      files.append(s);
  49.      end;
  50.  
  51.  
  52. Procedure DoubleDisplay;
  53. var i,j,k,half : integer;
  54.     s     : string;
  55.      begin
  56.      half := files.count div 2;
  57.      if ((half) * 2) <> files.count then files.append(' ');
  58.      half := files.count div 2;
  59.      OUT('Directory: '+root);
  60.      for i := 1 to half do
  61.           begin
  62.           s := files.fetchN(i) + ' | ' + files.fetchN(i+half);
  63.           OUT(s);
  64.           end;
  65.      totals.name := 'TOT('+integerstr(totfiles,3)+')';
  66.      s := FmtSearchRecK(totals);
  67.      OUT(' '+s);
  68.      end;
  69.  
  70.  
  71.  
  72. Procedure TripleDisplay;
  73. var i,j,k,third : integer;
  74.     s     : string;
  75.      begin
  76.      third := files.count div 3;
  77.      if ((third) * 3) <> files.count then files.append(' ');
  78.      if ((third) * 3) <> files.count then files.append(' ');
  79.      third := files.count div 3;
  80.      OUT('Directory: '+root);
  81.      for i := 1 to third do
  82.           begin
  83.           s := files.fetchN(i) + ' | ' + files.fetchN(i+third) + ' | ' +
  84.                files.fetchN(i+third+third);
  85.           OUT(s);
  86.           end;
  87.      totals.name := 'TOT('+integerstr(totfiles,3)+')';
  88.      s := FmtSearchRecK(totals);
  89.      OUT(' '+s);
  90.      end;
  91.  
  92.  
  93. Procedure DoIt;
  94.      begin
  95.      SearchEngine(root+filespec,anyfile,DealWithIt,Err);
  96.      files.sort;
  97.      if OUTCompressed then TripleDisplay
  98.      else DoubleDisplay;
  99.      end;
  100.  
  101.  
  102. Procedure Init;
  103. var i : integer;
  104.      begin
  105.      fillchar(totals,sizeof(totals),0);
  106.      totals.name := 'TOTAL';
  107.      totfiles := 0;
  108.      filespec := '*.*';
  109.      files.init(500);
  110.      if paramcount > 0 then
  111.           begin
  112.           if UpCaseStr(paramstr(1)) = 'P' then GetDir(0,root)
  113.           else root := paramstr(1);
  114.           end
  115.      else begin
  116.           GetDir(0,root);
  117.           end;
  118.      root := UpCaseStr(root);
  119.      i := pos('.',root);
  120.      if i = 0 then root := addbackslash(root);
  121.      StandardOUTInit;
  122.      end;
  123.  
  124.  
  125. (*  Main program *)
  126.      BEGIN
  127.      pProgID := 'DDIR 1.00';
  128.      init;
  129.      DoIt;
  130.      OUTdone;
  131.      end.
  132.  
  133.  
  134.